package com.luyang.platform.contact.infrastructure.repository;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.luyang.platform.contact.domain.user.repository.IUserRepository;
import com.luyang.platform.contact.domain.user.valueobject.Mobile;
import com.luyang.platform.contact.domain.user.model.User;
import com.luyang.platform.contact.domain.user.valueobject.UserId;
import com.luyang.platform.contact.infrastructure.dao.UserDao;
import com.luyang.platform.contact.infrastructure.entity.UserPO;
import org.springframework.stereotype.Repository;

/**
 * 用户信息仓储服务接口实现
 *
 * @author lu_yang
 */
@Repository
public class UserRepositoryImpl extends ServiceImpl<UserDao, UserPO> implements IUserRepository, IService<UserPO> {

    @Override
    public User find(Mobile mobile) {
        LambdaQueryWrapper<UserPO> queryWrapper = new LambdaQueryWrapper<UserPO>()
            .eq(UserPO::getMobile, mobile)
            .eq(UserPO::getHasDelete, Boolean.FALSE)
            .last("limit 0, 1");
        this.getOne(queryWrapper);
        return null;
    }

    @Override
    public User find(UserId userId) {
        LambdaQueryWrapper<UserPO> queryWrapper = new LambdaQueryWrapper<UserPO>()
            .eq(UserPO::getId, userId.value())
            .eq(UserPO::getHasDelete, Boolean.FALSE)
            .last("limit 0, 1");
        this.getOne(queryWrapper);
        return null;
    }
}
